﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Pavilion.NodeDesigner
{
    public class PavilionListBox : ListBox
    {
        static PavilionListBox()
        {
            //DefaultStyleKeyProperty.OverrideMetadata(typeof(PavilionListBox), new FrameworkPropertyMetadata(typeof(PavilionListBox)));
        }

        protected override DependencyObject GetContainerForItemOverride()
        {
            return new ListBoxItem();
        }

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var control = element as Control;
            control.MinHeight = 50;
            control.MinWidth = 50;

            control.Template = FindResource("PavilionListBoxItemContainer") as ControlTemplate;
            control.DataContext = item;

            Canvas.SetLeft(control, 1);
            Canvas.SetTop(control, 1);
            
            base.PrepareContainerForItemOverride(element, item);
        }
    }
}
